import Vue from 'vue'
import Vuex from 'vuex'

import {
  eduLessonPlanQuery,
  eduLessonPlanDelete,
  eduLessonPlanAdd,
  eduLessonPlanUpdate,
} from '@/api/admin/courseLibrary/eduLessonPlan.js'

Vue.use(Vuex)

const state = {}

const getters = {}

const actions = {
  async queryEduLessonPlan({ commit }, listQuery) {
    let res = await eduLessonPlanQuery({ ...listQuery })
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async deleteEduLessonPlan({ commit }, row) {
    let res = await eduLessonPlanDelete(row.id)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async addEduLessonPlan({ commit }, data) {
    let res = await eduLessonPlanAdd(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
  async updateEduLessonPlan({ commit }, data) {
    let res = await eduLessonPlanUpdate(data)
    return res.data.code == 0 ? res.data : Promise.reject(new Error('faile'))
  },
}

const mutations = {}

export default {
  state,
  getters,
  actions,
  mutations,
}
